package com.aaa.controller.api;

import com.aaa.entity.DictData;
import com.aaa.service.DictDataService;
import com.aaa.vo.AddOrUpdMenu;
import com.aaa.vo.DictDataVo;
import com.aaa.vo.Result;
import com.aaa.vo.RoleVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * @BelongsPackage: com.aaa.controller.api
 * @Description:
 * @CreateTime: 2023-03-22  19:13
 * @Author: ql
 */

@RestController
@RequestMapping("/system/api/dict/data")
public class ApiDictDataController {

    @Autowired
    private DictDataService dictDataService;

    @GetMapping("findByType/{type}")
    public Result<List<DictData>> list(@PathVariable String type){
        return dictDataService.findByType(type);
    }

    @PostMapping("/queryDictByPage")
    public Result<IPage<DictData>> queryDictByPage(@RequestBody DictDataVo dictDataVo){
        System.out.println("dictDataVo = " + dictDataVo);
        return dictDataService.queryDictByPage(dictDataVo);
    }
    @GetMapping("/getDictDataById/{id}")
    public Result<DictData> getDictDataById(@PathVariable Long id){
        System.out.println("-==================================="+id);

        return dictDataService.getDictDataById(id);
    }
    @GetMapping("/cacheAsync")
    public Result<String> cacheAsync(){
        return dictDataService.cacheAsync();
    }

    @PostMapping("/addOrUpdDictData")
    public Result<String> AddOrUpdDictData(@RequestBody DictData dictData){

        return dictDataService.addOrUpdDictData(dictData);
    }

    @DeleteMapping("/deleteDictDataByIds/{id}")
    public Result<String> deleteDictDataByIds(@PathVariable Long[] id){
        System.out.println("=========== " + Arrays.toString(id));
        return dictDataService.deleteDictDataByIds(id);

    }

}
